package com.xwltz.rbac.auth;

import cn.dev33.satoken.stp.StpUtil;

import java.lang.reflect.Field;
import java.time.LocalDateTime;

/**
 * @description SetCommonFiled
 * @information on version 1.0 be created by @xwltz at 2022/6/18 16:16
 */

public class SetCommonFiled<T> {

	public void set(T entity) {
		try {
			Field[] declaredFields = entity.getClass().getDeclaredFields();

			for (Field field : declaredFields) {
				var name = field.getName();
				if ("createTime".equals(name)) {
					field.set("createTime", LocalDateTime.now());
				}
			}
		} catch (IllegalAccessException ex) {
			ex.printStackTrace();
		}
	}
}
